<?php
	include "common.php";
	session_start();
	error_reporting(0);
	if($_SESSION['logInCheck']!=1){
		header('Location: index.php?loginInfo=false');
	}
	$userLink = $_SESSION['userLink'];
	$ID = $_SESSION['id'];
	$supervisor = $_SESSION['supervisor'];
	$userFname = $_SESSION['userFname'];
	$userLname = $_SESSION['userLname'];
	$role = $_SESSION['role'];
	
	$userSql = "SELECT * FROM user WHERE e_id = '$ID'";
	$userSqlQuery = mysql_query($userSql);
	$userSqlResult = mysql_fetch_assoc($userSqlQuery);
	
	$email = $userSqlResult['email'];
	$timezone_offset = 6; // for getting local time offset hrs
	$systemDate = gmdate('y-m-d', time()+$timezone_offset*60*60);
	$compToday = strtotime($systemDate);
	
	$noticeId = $_GET['carryName'];
	
	$noticeGiverSql = "UPDATE user SET status = 2 WHERE e_id = '$noticeId'";
	$noticeGiverSqlQuery = mysql_query($noticeGiverSql);
	
	$userSql = "SELECT * FROM user WHERE e_id = '$supervisor'";
	$userSqlQuery = mysql_query($userSql);
	$userSqlQueryResult = mysql_fetch_assoc($userSqlQuery);	
	
	$supervisor = $userSqlQueryResult['e_id'];
	$supervisorFname = $userSqlQueryResult['f_name'];
	$supervisorLname = $userSqlQueryResult['l_name'];
	
	$notificationUpdate = "UPDATE user SET notification=0 WHERE e_id = '$supervisor' ";
	$notificationUpdateQuery = mysql_query($notificationUpdate);
	
	$delete = $_GET['delete'];
	
	$deleteSql = "UPDATE black_box_message SET status = 0 WHERE id = '$delete'";
	$deleteSqlQuery = mysql_query($deleteSql);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="notification.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="show_report.css" />
<link rel="icon" type="image/ico" href="images/favicon.ico"></link> 
<link rel="shortcut icon" href="images/favicon.ico"></link>
<script src="curvycorners.src.js" type="text/javascript"></script>
<script src="login.js" type="text/javascript"></script>
<title><?php echo "Welcome to ".$userFname." ".$userLname; ?></title>
</head>
<body>
<div class="main_div_other">
	<p><img src="images/creato_logo.jpg" /></p>
    <p id="creatobd">www.creatobd.com</p>
    <p id="date"><script>document.write(new_month+" "+new_date+", "+old_date.getFullYear()+" || "+new_day);</script></p>
    <div class="other_page_icons">
    	<div class="new_notification">
        	<img src="images/arrow_up.JPG" /><?php if ($notification >0){?><p>You have<?php echo " ".$notification." ";?>new notification</p><?php }?>
        </div><!--end of new_notification-->
    	<ul>
        	<a href="ceo.php"><li><div id="home"></div><p>home</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="ceo_employee.php"><li><div id="employee"></div><p>employee</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="on_duty.php"><li><div id="onduty"></div><p>on duty</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="ceo_attendance.php" ><li><div id="attendance"></div><p>attendance</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="leave.php"><li><div id="leave"></div><p>leave</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="ceo_notification.php" class="active"><li><div id="notification"></div><p>notification</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="ceo_blackbox.php"><li><div id="blackbox"></div><p>black box</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="ceo_notice.php"><li><div id="hrpolicy"></div><p>hr policy</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="index.php"><li><div id="logout"></div><p>log out</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
        </ul>
    </div><!-- end of other_page_icons-->
    
</div><!-- end of main_div_other-->
<div class="othrpage_1">
    <p>View as : <a href="ceo_notification.php?check=1">Notification</a> | <a href="ceo_notification.php?check=2">Create Notice</a> |
	<a href="ceo_notification.php?check=3">Who Can Give Notice</a> | <a href="ceo_notification.php?check=4">Check Notice</a></p>
</div><!-- end of othrpage_1-->
<div class="page_content" style="margin-bottom:20px; margin-left:0px !important;">	
	<?php 
		$checkSubmit = $_GET['check'];
		if ($checkSubmit == 1)
			{
	?>
			<table  border="0" cellpadding="0" cellspacing="0" class="header_page_content" align="center">
						<tr class="table_header_1"  valign="top">
							<td align="center" colspan="8">Approval Requests</td>
						</tr>
						<tr valign="top" class="table_header_2">
							<td width="100px"><p>Employee Id</p></td>
							<td width="100px"><p>First Name</p></td>
							<td width="100px"><p>Last Name</p></td>
							<td width="100px"><p>Apply Type</p></td>		
							<td width="100px"><p>Reason</p></td>
							<td width="100px"><p>Accept</p></td>
							<td width="100px"><p>Reject</p></td>
						</tr>
			</table>			
			<?php			
					$sql = "SELECT * FROM notification WHERE supervisor = '$ID' and Status=2";
					$ifSupervisor = mysql_query($sql);
					//$noOfData = mysql_fetch_row($ifSupervisor);
					
					while ($ifSupervisorResult = mysql_fetch_array($ifSupervisor)){
						$supervisor = $ifSupervisorResult['supervisor'];
						$status = $ifSupervisorResult['Status'];
						$approvalType = $ifSupervisorResult['Type'];
						$referId = $ifSupervisorResult['reference_id'];
						
						$_SESSION['apply_type'] = $approvalType;
							
						//approval_type table SQL
						$approvalSql = "SELECT * FROM $approvalType WHERE id = '$referId' AND status=2";
						$approvalSqlQuery = mysql_query($approvalSql);
				?>	
					<table border="0" cellpadding="0" cellspacing="0" class="header_page_content" align="center">
						
							<?php			
									while ($data = mysql_fetch_assoc($approvalSqlQuery))
									{
										$id = $data['e_id'];
										$sql = "SELECT * FROM user WHERE e_id = '$id'";
										$sqlQuery = mysql_query($sql);
										$sqlQueryResult = mysql_fetch_assoc($sqlQuery);
										$_SESSION['applier'] = $data['e_id'];
										
										$myID = $ifSupervisorResult['id'];
									?>
									<tr valign="top" class="table_header_3">
										<td width="100px"><p><?php echo $data['e_id'];?></p></td>
										<td width="100px"><p><?php echo $sqlQueryResult['f_name'];?></p></td>
										<td width="100px"><p><?php echo $sqlQueryResult['l_name'];?></p></td>
										<td width="100px"><p><?php echo $approvalType;?></p></td>
										<td width="100px"><p><?php echo $data['reason'];?></p></td>
										<td width="100px"><p><a href="ceo_notificatn.php?id=1&type=<?php echo $approvalType;?>&row=<?php echo $myID;?>">Accept</a></p></td>
										<td width="100px"><p><a href="ceo_notificatn.php?id=0&type=<?php echo $approvalType;?>&row=<?php echo $myID;?>">Reject</a></p></td>
									</tr>
								<?php
									}
								} 
							 ?>	
					</table>
				<?php
					}
					if ($checkSubmit == 2)
					{
				?>
					<p class="header_page_content"></p>
					 <form method="post" action="ceo_get_notice.php">
					 	<table cellpadding="0" cellspacing="0" border="0" align="center" class="hrpage_info_table">		
							<tr valign="top">
								<td class="add_user_td1">Notice Type</td>
								<td>
									<select name="noticeType">
										<option value="holiday">Holiday</option>
										<option value="work">Work</option>
										<option value="meeting">Meeting</option>
										<option value="work">Meeting</option>
										<option value="other">Others</option>												
									</select>
								</td>
								<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>
							</tr>
							<tr valign="top">
								<td class="add_user_td1">Date From</td>
								<td>
									<select name="day">
										<option value="Day">Day</option>
										<option value="1">1</option>
										<option value="2">2</option>
										<option value="3">3</option>
										<option value="4">4</option>
										<option value="5">5</option>
										<option value="6">6</option>
										<option value="7">7</option>
										<option value="8">8</option>
										<option value="9">9</option>
										<option value="10">10</option>
										<option value="11">11</option>
										<option value="12">12</option>
										<option value="13">13</option>
										<option value="14">14</option>
										<option value="15">15</option>
										<option value="16">16</option>
										<option value="17">17</option>
										<option value="18">18</option>
										<option value="19">19</option>
										<option value="20">20</option>
										<option value="21">21</option>
										<option value="22">22</option>
										<option value="23">23</option>
										<option value="24">24</option>
										<option value="25">25</option>
										<option value="26">26</option>
										<option value="27">27</option>
										<option value="28">28</option>
										<option value="29">29</option>
										<option value="30">30</option>
										<option value="31">31</option>
									</select>
									
									<select name="month"> 
										<option value="month">Month</option><option value="1">January</option>
										<option value="2">February</option><option value="3">March</option><option value="4">April</option>
										<option value="5">May</option><option value="6">June</option><option value="7">July</option>
										<option value="8">August</option><option value="9">September</option><option value="10">October</option>
										<option value="11">November</option><option value="12">December</option>
									</select>
									<select name="year">
										<option value="year">Year</option>
										<option value="2012">2012</option>
										<option value="2013">2013</option>
										<option value="2014">2014</option>
										<option value="2015">2015</option>
										<option value="2016">2016</option>
										<option value="2017">2017</option>
										<option value="2018">2018</option>
										<option value="2019">2019</option>
										<option value="2020">2020</option>
									</select>
								</td>
								<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>
							</tr>
							<tr valign="top">
								<td class="add_user_td1">Date To</td>
								<td>
									<select name="day1">
			
										<option value="Day">Day</option>
										<option value="1">1</option>
										<option value="2">2</option>
										<option value="3">3</option>
										<option value="4">4</option>
										<option value="5">5</option>
										<option value="6">6</option>
										<option value="7">7</option>
										<option value="8">8</option>
										<option value="9">9</option>
										<option value="10">10</option>
										<option value="11">11</option>
										<option value="12">12</option>
										<option value="13">13</option>
										<option value="14">14</option>
										<option value="15">15</option>
										<option value="16">16</option>
										<option value="17">17</option>
										<option value="18">18</option>
										<option value="19">19</option>
										<option value="20">20</option>
										<option value="21">21</option>
										<option value="22">22</option>
										<option value="23">23</option>
										<option value="24">24</option>
										<option value="25">25</option>
										<option value="26">26</option>
										<option value="27">27</option>
										<option value="28">28</option>
										<option value="29">29</option>
										<option value="30">30</option>
										<option value="31">31</option>
									</select>
									<select name="month1"> 
										<option value="month">Month</option><option value="1">January</option>
										<option value="2">February</option><option value="3">March</option><option value="4">April</option>
										<option value="5">May</option><option value="6">June</option><option value="7">July</option>
										<option value="8">August</option><option value="9">September</option><option value="10">October</option>
										<option value="11">November</option><option value="12">December</option>
									</select>
									<select name="year1">
										<option value="year">Year</option>
										<option value="2012">2012</option>
										<option value="2013">2013</option>
										<option value="2014">2014</option>
										<option value="2015">2015</option>
										<option value="2016">2016</option>
										<option value="2017">2017</option>
										<option value="2018">2018</option>
										<option value="2019">2019</option>
										<option value="2020">2020</option>
									</select>
								</td>
								<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>
							</tr>
							<tr valign="top">
								<td class="add_user_td1">Notice For</td>
								<td><textarea rows="7" cols="52" name="notice_for"></textarea></td>
								<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>
							</tr>
							<tr><td colspan="3"><p class="submit_button_add_user"><input type="submit" value="Submit" /></p></td></tr>
						</table>
					</form>
				<?php 
					}
					if ($checkSubmit == 3)
					{
					$userSql = "SELECT * FROM user WHERE status = 0 or status = 2";
					$userSqlQuery = mysql_query($userSql);					
				?>
					<table  border="0" cellpadding="0" cellspacing="0" class="header_page_content" align="center">
						<tr class="table_header_1"  valign="top">
							<td align="center" colspan="8">Approve Who can give Notice</td>
						</tr>
						<tr valign="top" class="table_header_2">
							<td width="100px"><p>Employee Id</p></td>
							<td width="100px"><p>First Name</p></td>
							<td width="100px"><p>Last Name</p></td>
							<td width="100px"><p>Approve</p></td>		
						</tr>
					</table>
					<table border="0" cellpadding="0" cellspacing="0" class="header_page_content" align="center">
						<?php
							while($data = mysql_fetch_assoc($userSqlQuery))
							{						
								$id = $data['e_id'];
								$sql = "SELECT * FROM user WHERE e_id = '$id'";
								$sqlQuery = mysql_query($sql);
								$sqlQueryResult = mysql_fetch_assoc($sqlQuery);
						?>
						<tr valign="top" class="table_header_3">
							<td width="100px;"><p><?php echo $id;?></p></td>
							<td width="100px;"><p><?php echo $sqlQueryResult['f_name'];?></p></td>
							<td width="100px;"><p><?php echo $sqlQueryResult['l_name'];?></p></td>
							<td width="100px;"><p><a href="ceo_notification.php?carryName=<?php echo $id;?>">Approve</a></p></td>
						</tr>
						<?php
							}
						?>	
					</table>
				<?php 
					}
					if ($checkSubmit == 4)
					{
						$sql = "SELECT * FROM notice_board WHERE status = 1";
						$sqlQuery = mysql_query($sql);
				?>
						<table  border="0" cellpadding="0" cellspacing="0" class="header_page_content" align="center">
							<tr class="table_header_1"  valign="top">
								<td align="center" colspan="8">Approval Requests</td>
							</tr>
							<tr valign="top" class="table_header_2">
								<td width="100px"><p>Notice Type</p></td>
								<td width="100px"><p>Valid From</p></td>
								<td width="100px"><p>Valid To</p></td>
								<td width="100px"><p>Description</p></td>		
								<td width="100px"><p>Delete</p></td>
							</tr>
    					</table>
						<table border="0" cellpadding="0" cellspacing="0" class="header_page_content" align="center">
								<?php			
										while ($data = mysql_fetch_assoc($sqlQuery))
										{
										?>
										<tr valign="top" class="table_header_3">
											<td width="100px"><p><?php echo $data['notice_type'];?></p></td>
											<td width="100px"><p><?php echo $data['from_date'];?></p></td>
											<td width="100px"><p><?php echo $data['to_date'];?></p></td>
											<td width="100px"><p><?php echo $data['description'];?></p></td>
											<td width="100px"><p><a href="ceo_notice.php?delete=<?php echo $data['id'];?>">Delete</a></p></td>
										</tr>
									<?php
										} 
								 ?>	
							
						</table>
				<?php 
					}
				?>
				
    </div><!-- end of page_content -->
    <div class="human_portal">
  		<p>creato human resourse portal</p>
</div><!-- end of human_portal-->

</body>
</html>
